<script setup lang="ts">
import {ref} from 'vue'
import {StnIpt} from 'st-ui-vue3-navie'
import {ResponsiveCollapseSearch} from '@components'
import {useSysDictStore} from '../stores/sys-dict-store'
import {DictIptPropsPathEnum} from '../enums/dict-ipt-props-path-enum.ts'
import {DictObjPropNameEnum} from '../enums/dict-obj-prop-name-enum.ts'

// 搜索表单
const searchForm = ref({
  [DictObjPropNameEnum.NAME]: '',
  [DictObjPropNameEnum.CODE]: '',
  [DictObjPropNameEnum.DISABLED]: null,
})

/**
 * 搜索处理函数
 */
const searchHandler = async (searchFormData: Record<string, any>) => {
  return await useSysDictStore().getTableDataByReq(searchFormData)
}
</script>

<template>
  <ResponsiveCollapseSearch
    :search-form-default="searchForm"
    :search-handler="searchHandler"
  >
    <StnIpt
      v-model:value="searchForm[DictObjPropNameEnum.NAME]"
      :predefine-props="DictIptPropsPathEnum.NAME"
    />
    <StnIpt
      v-model:value="searchForm[DictObjPropNameEnum.CODE]"
      :predefine-props="DictIptPropsPathEnum.CODE"
    />
    <StnIpt
      v-model:value="searchForm[DictObjPropNameEnum.DISABLED]"
      :predefine-props="DictIptPropsPathEnum.DISABLED"
    />
  </ResponsiveCollapseSearch>
</template> 